package org.neuedu.chapter09_0701.practice04;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class Practice04 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入北京时间");
        String str = scan.nextLine();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date bjDate = sdf.parse(str);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(bjDate);
            calendar.add(Calendar.HOUR_OF_DAY,-7);
            System.out.println("巴黎时间:" + calendar.getTime());
            calendar.add(Calendar.HOUR_OF_DAY,-5);
            System.out.println("纽约时间:" + calendar.getTime());
        } catch (ParseException e) {
            System.out.println("无法解析该时间格式");
        }
    }
}
